<%@ page language="java" contentType="text/html;charset=utf-8"
	pageEncoding="utf-8"%>
<%@ page import="java.util.*"%>
<%@ page import="com.sms.note.*"%>

<%
	//清除内存
	response.setHeader("Pragma","No-cache"); 
	response.setHeader("Cache-Control","no-cache"); 
	response.setDateHeader("Expires", 0);
%>


<%
	request.setCharacterEncoding("utf-8");
	String userno = (String)session.getAttribute("userno");
	
	String row = request.getParameter("id");//获取该公告是第几行的参数(从0开始的)
	int num = Integer.parseInt(row);
	System.out.print(num);
	List<Map> jlist=Note.getdetailinfo(num);
	//System.out.print(jlist.size());	
	Note note= new Note();
	if(jlist != null && jlist.size() > 0) {
		Map map1=jlist.get(0);
		//得到该公告的对象并赋值
		note.init(map1);
	} else {
		System.out.println("error");
	}
%>
<style type="text/css">
label {
	font-weight: bolder;
}
.hidden{
   display:none;
}
</style>
<body>
	<div id="work" style="padding:20px">

		<form id="detail_form">
 
            <input type="hidden" name='infoid' id="infoid" value="<%=num%>"> 
			<table cellpadding="0" cellspacing="0" width="100%" height="100%">
				<tr>
					<td width='10%' align="center"><label for="name">发布者:</label>
					</td>
					<td style="text-align:left;height:30px;"><%=note.getFromname()%></td>
				</tr>
				<tr>
					<td align="center"><label for="desc">发布日期:</label>
					</td>
					<td><%=note.getNotetime()%></td>
				</tr>
				<tr>
					<td align="center"><label for="begintime" style="width:110px;">标题：</label>
					</td>
					<td style="text-align:left;height:30px;"><input type="text" name='title'
						style="height:100%;width:100%;border:0" value="<%=note.getTitle()%>"></td>
				</tr>
				<tr>
					<td align="center"><label for="begintime" style="width:110px;">内容</label>
					</td>
					<td style="text-align:left;height:100px;"><textarea name='content'
							style="border:0;height:100%; width:100% "><%=note.getContent()%></textarea>
					</td>
				</tr>
				<tr>
					<td align="center"><label for="deadline" style="width:110px;">浏览次数：</label>
					</td>
					<td style="text-align:left;height:30px;" id="changetime"><%=note.getReadnum()%></td>
				</tr>
				
				<!-- 附件信息 ####################################  -->
				<%
					List<Map> appendFile = null;
										//如果有附件
										if(note.getIsappend().equals("1")) {
										//System.out.println("有附件");
									appendFile = new ArrayList<Map>();
									appendFile = note.getAppendFile();
									for(int i=0; i<appendFile.size(); i++) {
				%>
				<tr class="addfiles">
					<td align="center"><label for="file">公告附件链接：</label>
					</td>
					<td style="text-align:left;height:30px;">
						<%
							Map<String, String> map = (Map<String, String>)appendFile.get(i);
														      				String type=(String)map.get("type");
																	String fileName = (String)map.get("fileName");
																	String saveName = (String)map.get("saveName");
						%> <a
						href="DownServlet?fileName=<%=fileName%>&saveName=<%=saveName%>"><%=type+i+":"+fileName%></a>&nbsp;&nbsp;
						<%
							}
						%>
						<!-- 
			            <input type="button" id="delfile" value="删除附件" />&nbsp;&nbsp;
						<input type="button" id="modfile" value="修改附件" />
						 -->
					</td>
				</tr>
				<!-- 
				<tr id="modfilearea" class='hidden' style="">
					<td id='file_operate' colspan="2" style="height:30px;text-align:left;">
					    <label>&nbsp;&nbsp;&nbsp;&nbsp;修改原附件:&nbsp;&nbsp;&nbsp;&nbsp;</label>
					    <input type="file" /><br />
					     <label>&nbsp;&nbsp;&nbsp;&nbsp;新增附件:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</label>
					    <input type="file" />
					    <input type="button" id="returnbutton" value='返回' />
					</td>
				</tr>
				 -->
				<%
					}
				%>							
				<!-- ###############################################  -->
				
				<tr>
					<td id='before' colspan="2" class="tip" style="text-align:left;">** &nbsp;&nbsp;未修改任何内容请不要提交！</td>
				</tr>	
				<tr>
					<td align="center" colspan="2">
					<input type="submit" id="submit" value="保存" />
					</td>
				</tr>
			</table>

			

		</form>



	</div>

	<script type="text/javascript">
		$(document).ready(function() {
		  /*  $("#modfile").click(function(){
		        $("#modfilearea").toggleClass('hidden');
		    }); 
		    $("#returnbutton").click(function(){
		        $("#modfilearea").addClass('hidden');
		    });
		*/
		
		
		
		
		
		
			$("#detail_form").submit(function(event) {
		    	event.preventDefault();
				var title = $("input[name='title']").val();
				var content = $("textarea[name='content']").val();	
				
				alert(title);
				if (title&&content) {
				        
					$.post("public_report/teacher/updatenote.jsp",$("#detail_form").serialize(),function(data){
					alert(data);
					
					
					});
				} else {
					alert('请补充完整信息');
					return false;
				}
			});
		});
	</script>